package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicMaterialReturnItemDAO;
import com.cssy.yd.logic.entity.LogicMaterialReturnItemDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-08-27
 */
public class LogicMaterialReturnItemDAOImpl extends SqlMapClientDaoSupport implements LogicMaterialReturnItemDAO {

    /**
     * 插入数据
     * @param logicMaterialReturnItemDO
     * @return 插入数据的主键
     */
    public String insertLogicMaterialReturnItemDO(LogicMaterialReturnItemDO logicMaterialReturnItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicMaterialReturnItem.insert", logicMaterialReturnItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicMaterialReturnItemDO
     * @return 查出的记录数
     */
    public Integer countLogicMaterialReturnItemDOByExample(LogicMaterialReturnItemDO logicMaterialReturnItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicMaterialReturnItem.countByDOExample", logicMaterialReturnItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicMaterialReturnItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicMaterialReturnItemDO(LogicMaterialReturnItemDO logicMaterialReturnItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicMaterialReturnItem.update", logicMaterialReturnItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicMaterialReturnItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicMaterialReturnItemDO> findListByExample(LogicMaterialReturnItemDO logicMaterialReturnItemDO) throws DataAccessException {
        List<LogicMaterialReturnItemDO> list = getSqlMapClientTemplate().queryForList("LogicMaterialReturnItem.findListByDO", logicMaterialReturnItemDO);
        return list;
    }

    /**
     * 根据主键获取logicMaterialReturnItemDO
     * @param id
     * @return logicMaterialReturnItemDO
     */
    public LogicMaterialReturnItemDO findLogicMaterialReturnItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicMaterialReturnItemDO logicMaterialReturnItemDO = (LogicMaterialReturnItemDO) getSqlMapClientTemplate().queryForObject("LogicMaterialReturnItem.findByPrimaryKey", id);
        return logicMaterialReturnItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicMaterialReturnItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicMaterialReturnItem.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicMaterialReturnItemDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicMaterialReturnItemDO> list = getSqlMapClientTemplate().queryForList("LogicMaterialReturnItem_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicMaterialReturnItem_ex.count", scs);
  	      return count;
  	}
	
	@Override
	public List<LogicMaterialReturnItemDO> findByMaReturnid(String mareturnid)
			throws DataAccessException {
		List<LogicMaterialReturnItemDO> list = getSqlMapClientTemplate().queryForList("LogicMaterialReturnItem_ex.findByMaReturnid", mareturnid);
		return list;
	}

	@Override
	public void deleteByMaReturnid(String mareturnid) throws DataAccessException {
		getSqlMapClientTemplate().delete("LogicMaterialReturnItem_ex.deleteByMaReturnid", mareturnid);
	}
}